package br.com.cast.syscast;

import org.apache.wicket.MarkupContainer;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.Panel;

import br.com.cast.syscast.municipio.paginas.ListarMunicipio;
import br.com.cast.syscast.pais.paginas.ListarPais;
import br.com.cast.syscast.uf.paginas.ListarUf;
import br.com.cast.syscast.util.ComponentUtil;

public class Menu extends Panel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public Menu(String id) {
		super(id);

		add(new Link("manterPais") {
			@Override
			public void onClick() {
				MarkupContainer template = 
						ComponentUtil.getTemplate(this);
				getParent().getParent();

				template.replace(new ListarPais(HomePage.ID_CONTEUDO));
			}
		});

		add(new Link("manterUf") {
			@Override
			public void onClick() {
				MarkupContainer template = 
						ComponentUtil.getTemplate(this);

				template.replace(new ListarUf(HomePage.ID_CONTEUDO));
			}
		});
		
		add(new AjaxLink("manterMunicipio") {

			@Override
			public void onClick(AjaxRequestTarget target) {
				MarkupContainer template = 
						ComponentUtil.getTemplate(this);

				ListarMunicipio listar = new ListarMunicipio(HomePage.ID_CONTEUDO);
				template.replace(listar);
				
				target.add(listar);
				
				
			}
		});
	}

}
